package com.enation.app.javashop.api.client;

import com.enation.app.javashop.model.statistics.dto.GoodsData;
import com.enation.app.javashop.service.statistics.GoodsDataManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 商品收集 client controller
 *
 * @author chopper
 * @version v1.0
 * @Description:
 * @since v7.0
 * 2018/5/8 下午4:11
 */

@RestController
@RequestMapping("/client/statistics")
@Validated
@ApiIgnore
public class GoodsDataClientController {
    @Autowired
    private GoodsDataManager goodsDataManager;
    /**
     * 新增商品
     *
     * @param goodsIds 商品id
     */
    @RequestMapping(value = "/goods/add", method = RequestMethod.POST)
    public void addGoods(@RequestParam("goods_ids") Long[] goodsIds){
        goodsDataManager.addGoods(goodsIds);
    }

    /**
     * 修改商品
     *
     * @param goodsIds 商品id
     */
    @RequestMapping(value = "/goods/update", method = RequestMethod.POST)
    public void updateGoods(@RequestParam("goods_ids") Long[] goodsIds){
        goodsDataManager.updateGoods(goodsIds);
    }

    /**
     * 删除商品
     *
     * @param goodsIds 商品id
     */
    @RequestMapping(value = "/goods/del", method = RequestMethod.POST)
    public void deleteGoods(@RequestParam("goods_ids") Long[] goodsIds){
        goodsDataManager.deleteGoods(goodsIds);
    }

    /**
     * 修改商品收藏数量
     *
     * @param goodsData
     */
    @RequestMapping(value = "/collection/goods", method = RequestMethod.POST)
    public void updateCollection(@RequestBody GoodsData goodsData){
        goodsDataManager.updateCollection(goodsData);
    }


    @RequestMapping(value = "/goods/under", method = RequestMethod.POST)
    public void underAllGoods(@RequestParam("seller_id")Long sellerId) {
        goodsDataManager.underAllGoods(sellerId);
    }

}
